<div class="layui-tab layui-tab-brief tool-tab" lay-filter="tool-tab">
    <ul class="layui-tab-title text">
        <li class="layui-this">可解密加密</li>
        <li>MD5加密</li>
        <li>Base64加密</li>
    </ul>
    <div class="layui-tab-content">
        <!-- 可解密加密 -->
        <div class="layui-tab-item layui-show">
            <blockquote class="layui-elem-quote tools-title">
                <p><span class="font-red">注意：</span></p>
                <ol>
                    <li>这种加密方式需要密钥，一定要记住，不然以后密码就找不回来！</li>
                    <li>同样的密码，哪怕是密钥是一样的，加密的结果都是不一样的！</li>
                    <li>可以设定密码有效时间，单位秒(s)，0 为永久有效！</li>
                    <li>一定要记住密钥！</li>
                </ol>
            </blockquote>
            <div class="layui-row layui-col-space10">
                <div class="layui-col-sm12 layui-col-md6">
                    <fieldset class="layui-elem-field">
                        <legend>加密</legend>
                        <div class="layui-field-box">
                            <form class="layui-form" lay-filter="form_encode" action="">
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">加密内容</label>
                                    <div class="layui-input-block">
                                        <textarea name="c" lay-verify="required" placeholder="请输入需要加密内容" class="layui-textarea"></textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">加密密钥</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="k" value="WJSSK" required lay-verify="required" placeholder="请输入加密密钥" autocomplete="off" class="layui-input">
                                    </div>
                                    <div class="layui-form-mid layui-word-aux font-red">一定不能忘记！</div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">密码有效期</label>
                                    <div class="layui-input-inline">
                                        <input type="number" name="t" value="0" required lay-verify="required|number" placeholder="请输入密码有效期" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item text-center">
                                    <button class="layui-btn layui-btn-normal layui-btn-sm" lay-submit lay-filter="save_form_encode">加密</button>
                                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">清空</button>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">加密结果</label>
                                    <div class="layui-input-block">
                                        <textarea disabled="disabled" placeholder="加密结果" class="layui-textarea encode-rs"></textarea>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </fieldset>
                </div>
                <div class="layui-col-sm12 layui-col-md6">
                    <fieldset class="layui-elem-field">
                        <legend>解密</legend>
                        <div class="layui-field-box">
                            <form class="layui-form" lay-filter="form_encode" action="">
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">解密内容</label>
                                    <div class="layui-input-block">
                                        <textarea name="c" lay-verify="required" placeholder="请输入需要加密内容" class="layui-textarea"></textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">加密密钥</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="k" value="WJSSK" required lay-verify="required" placeholder="请输入加密密钥" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item text-center">
                                    <button class="layui-btn layui-btn-normal layui-btn-sm" lay-submit lay-filter="save_form_decode">解密</button>
                                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">清空</button>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">解密结果</label>
                                    <div class="layui-input-block">
                                        <textarea  disabled="disabled" placeholder="解密结果" class="layui-textarea encode-rs"></textarea>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </fieldset>
                </div>
            </div>
        </div>
        <!-- MD5加密 -->
        <div class="layui-tab-item">
            <form class="layui-form" lay-filter="form_encode" action="">
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">加密内容</label>
                    <div class="layui-input-block">
                        <textarea name="c" lay-verify="required" placeholder="请输入需要加密内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item text-center">
                    <button class="layui-btn layui-btn-normal layui-btn-sm" lay-submit lay-filter="save_md5_encode">加密</button>
                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">清空</button>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">加密结果(16进制)</label>
                    <div class="layui-input-block">
                        <textarea  disabled="disabled" placeholder="加密结果(16进制)" class="layui-textarea encode-rs-16"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">加密结果(32进制)</label>
                    <div class="layui-input-block">
                        <textarea  disabled="disabled" placeholder="加密结果(32进制)" class="layui-textarea encode-rs-32"></textarea>
                    </div>
                </div>
            </form>
        </div>
        <!-- Base64加密 -->
        <div class="layui-tab-item">
            <form class="layui-form" lay-filter="form_encode" action="">
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">加密/解密 内容</label>
                    <div class="layui-input-block">
                        <textarea name="c" lay-verify="required" placeholder="请输入需要加密/解密 内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item text-center">
                    <button class="layui-btn layui-btn-normal layui-btn-sm" lay-submit lay-filter="save_base64_encode">加密</button>
                    <button class="layui-btn layui-btn-warm layui-btn-sm" lay-submit lay-filter="save_base64_decode">解密</button>
                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">清空</button>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">结果</label>
                    <div class="layui-input-block">
                        <textarea  disabled="disabled" placeholder="结果" class="layui-textarea encode-rs"></textarea>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    layui.use(['jquery', 'layer','form'], function () {
        var $ = layui.jquery,
            l = layui.layer,
            f = layui.form;

        f.on('submit(save_form_encode)',function (obj){
            var load = l.load(2);
                rs_area = $(obj.form).find('.encode-rs');
            $.get('__API__/setpwd/mcrypt_e',obj.field,function (rs){
                console.log(rs);
                rs_area.val(rs);
                l.close(load);
            },'html');
            return false;
        });

        f.on('submit(save_form_decode)',function (obj){
            var load = l.load(2);
            rs_area = $(obj.form).find('.encode-rs');
            $.get('__API__/setpwd/mcrypt_d',obj.field,function (rs){
                console.log(rs);
                rs_area.val(rs);
                l.close(load);
            },'html');
            return false;
        });

        f.on('submit(save_md5_encode)',function (obj){
            var load = l.load(2);
            rs_area_16 = $(obj.form).find('.encode-rs-16');
            rs_area_32 = $(obj.form).find('.encode-rs-32');
            var field = {};
            field['c'] =  obj.field.c;
            field['type'] =  1;

            $.get('__API__/setpwd/encode',field,function (rs){
                console.log(rs);
                rs_area_16.val(rs.data['16']);
                rs_area_32.val(rs.data['32']);
                l.close(load);
            },'json');
            return false;
        });

        f.on('submit(save_base64_encode)',function (obj){
            var load = l.load(2);
            rs_area = $(obj.form).find('.encode-rs');
            var field = {};
            field['c'] =  obj.field.c;
            field['type'] =  2;

            $.get('__API__/setpwd/encode',field,function (rs){
                console.log(rs);
                rs_area.val(rs.data);
                l.close(load);
            },'json');
            return false;
        });

        f.on('submit(save_base64_decode)',function (obj){
            var load = l.load(2);
            rs_area = $(obj.form).find('.encode-rs');
            var field = {};
            field['c'] =  obj.field.c;
            field['type'] =  2;

            $.get('__API__/setpwd/decode',field,function (rs){
                console.log(rs);
                rs_area.val(rs.data);
                l.close(load);
            },'json');
            return false;
        });
    });
</script>